#if 0
#include <buola/gui.h>

#include <buola/widgets/cwizard.h>
#include <buola/widgets/cbutton.h>

#include <buola/widgets/cdialoglayoutmanager.h>
#include <buola/image/cfont.h>
#include <buola/image/cgc.h>

namespace buola { namespace gui {

CWizard::CWizard()
{
    mCurPage=-1;

    mNextSet=true;
    mPrevSet=true;
    mFinishSet=false;
    mCancelSet=true;
}

CWizard::~CWizard()
{
}

void CWizard::SetNext(bool pNextSet)
{
    mNextSet=pNextSet;
    EnableButtons();
}

void CWizard::SetPrev(bool pPrevSet)
{
    mPrevSet=pPrevSet;
    EnableButtons();
}

void CWizard::SetFinish(bool pFinishSet)
{
    mFinishSet=pFinishSet;
    EnableButtons();
}

void CWizard::SetCancel(bool pCancelSet)
{
    mCancelSet=pCancelSet;
    EnableButtons();
}

void CWizard::Next()
{
    if(!CanNext()) return;

    for(int i=mCurPage+1;i<mPages.size();i++)
    {
        if(mPages[i]->mEnabled)
        {
            ShowPage(mPages[i]);
            return;
        }
    }
}

void CWizard::Prev()
{
    if(!CanPrev()) return;

    for(int i=mCurPage-1;i>=0;i--)
    {
        if(mPages[i]->mEnabled)
        {
            ShowPage(mPages[i]);
            return;
        }
    }
}

void CWizard::Finish()
{
}

void CWizard::Cancel()
{
}

void CWizard::AddPage(TID pID,const std::wstring &pName,const img::CPicture &pImage,CWindow *pWindow)
{
    CWizardPage *lPage=new CWizardPage(mPages.size(),pID,pName,pImage,pWindow);
    mPages.push_back(lPage);
    EnableButtons();
    
    if(mCurPage<0)      //Show if it's the first page
    {
        ShowPage(lPage);
    }
}

void CWizard::InsertPage(int pPos,TID pID,const std::wstring &pName,const img::CPicture &pImage,
                        CWindow *pWindow)
{
    CWizardPage *lPage=new CWizardPage(pID,pPos,pName,pImage,pWindow);
    mPages.insert(mPages.begin()+pPos,lPage);
    for(int i=pPos+1;i<mPages.size();i++)
    {
        mPages[i]->mPos=i;
    }
}

void CWizard::RemovePage(CWizardPage *pPage)
{
    int i=std::find(mPages.begin(),mPages.end(),pPage)-mPages.begin();

    if(i<0)
    {
        throw XNotFound("Wizard page not found while removing");
    }
    
    if(mCurPage>=0&&mPages[mCurPage]==pPage)
    {
        throw XArgument("Can't remove current page");
    }

    delete mPages[i];
    mPages.erase(mPages.begin()+i);

    for(;i<mPages.size();i++)
    {
        mPages[i]->mPos=i;
    }
}

void CWizard::ShowPage(CWizardPage *pPage)
{
    if(mCurPage==pPage->mPos) return;

    CWizardPage *lOld;

    if(!pPage->mWindow)
    {
        OnPageNeeded(pPage);
    
        if(!pPage->mWindow)
        {
            throw XNotFound("Wizard page doesn't exist in ShowPage()");
        }
    }
    
    if(mCurPage>=0)     //Hide current page
    {
        lOld=mPages[mCurPage];
        mPages[mCurPage]->mWindow->Show(false);
    }
    else
    {
        lOld=nullptr;
    }

    mCurPage=pPage->mPos;

    if(!pPage->mShown)
    {
        CDialogLayoutManager::Get(this)->Between(pPage->mWindow,1,5,2,6);
        pPage->mShown=true;
    }
    
    pPage->mWindow->Show();
    pPage->mWindow->SetFocusToChild();
    
    OnPageChanged(lOld,pPage);

    EnableButtons();
}

void CWizard::EnableButtons()
{
    bool lSet=false;
    
    for(int i=mCurPage+1;i<mPages.size();i++)
    {
        if(mPages[i]->mEnabled) 
        {
            lSet=true;
            break;
        }
    }

    if(mNextSet&&lSet)
        mNext->UnsetStyleBit(STYLE_DISABLED);
    else
        mNext->SetStyleBit(STYLE_DISABLED);

    lSet=false;
    
    for(int i=0;i<mCurPage;i++)
    {
        if(mPages[i]->mEnabled) 
        {
            lSet=true;
            break;
        }
    }

    if(mPrevSet&&lSet)
        mPrev->UnsetStyleBit(STYLE_DISABLED);
    else
        mPrev->SetStyleBit(STYLE_DISABLED);

    if(mFinishSet)
        mFinish->UnsetStyleBit(STYLE_DISABLED);
    else
        mFinish->SetStyleBit(STYLE_DISABLED);

    if(mCancelSet)
        mCancel->UnsetStyleBit(STYLE_DISABLED);
    else
        mCancel->SetStyleBit(STYLE_DISABLED);

}

void CWizard::Shape()
{
    CSize_d lSize;

    lSize.x=500;
    lSize.y=400;

    CPoint_d lPos(300,300);

    MoveResize(lPos,lSize);
}

///////////////// events //////////////////

void CWizard::OnCreate()
{
    mFont=img::CFont::GetStock(L"control");

    Shape();

    mNext=new CButton;
    mNext->ePressed.Connect(&CWizard::Next,this);
    mNext->Create(this);
    mNext->SetCaption(L"Next");

    mPrev=new CButton;
    mPrev->ePressed.Connect(&CWizard::Prev,this);
    mPrev->Create(this);
    mPrev->SetCaption(L"Previous");

    mFinish=new CButton;
    mFinish->ePressed.Connect(&CWizard::OnFinish,this);
    mFinish->Create(this);
    mFinish->SetCaption(L"Finish");

    mCancel=new CButton;
    mCancel->ePressed.Connect(&CWizard::OnCancel,this);
    mCancel->Create(this);
    mCancel->SetCaption(L"Cancel");

    CDialogLayoutManager *lLayout=CDialogLayoutManager::Get(this);

    lLayout->AddVLine(1,20);
    lLayout->AddVLine(2,WLAY_RIGHT-20);
    lLayout->AddHLine(3,WLAY_BOTTOM-50);
    lLayout->AddHLine(4,WLAY_BOTTOM-20);
    lLayout->AddHLine(5,20);
    lLayout->AddHLine(6,WLAY_BOTTOM-70);

    lLayout->Array(WLAY_HORIZ,0,1,3,2,4,7,mCancel,nullptr,nullptr,
                                        mPrev,mNext,nullptr,mFinish);
    EnableButtons();

    mNext->Show();
    mPrev->Show();
    mFinish->Show();
    mCancel->Show();
}

void CWizard::OnExpose(const CExposeEvent &pE)
{
    img::CGC *lGC=pE.mGC;
    
    lGC->SetFont(mFont);

    if(GetCurPage())
        lGC->DrawText(CPoint_d(20,20),GetCurPage()->mText);
}

/*namespace gui*/ } /*namespace buola*/ }
#endif